<template>
	<div class="main">
		<!-- <div class="title">{{sonItem.name}}{{sonItemid}}</div> -->
		<div class="title" :sid="sonItemid">{{sonItem.name}}</div>
		<div class="main_item" v-for="item in sonItem.content" :key="item.id">
			<div class="item_name" @click= "handelClick(item.name)">{{item.name}}</div>
			<div class="item_content">
				<span v-for="subitem in item.content" :key="subitem.id" @click= "handelClick(subitem.name)" >{{subitem.name}}</span>
			</div>
		</div>
	</div>
</template>

<script>
// 导入请求数据的 baseurl
import baseUrl from '@/utils/urlconfig'
export default {
  props: ['sonItem', 'sonItemid'],
  data () {
    return {
      newarray: null
    }
  },
  methods: {
	  async handelClick (name) {
	    console.log(name)
	    // var url = baseUrl + '/menu/menu_detail/?kw=' + name
	    // const { data: res } = await this.$http.get(url)
	    // if (res.message === 'OK') {
	  	  // localStorage.removeItem('goodsList')
	  	  // console.log(res.data)
	  	  // localStorage.setItem('goodsList', JSON.stringify(res.data.first_title))
	  	  this.$router.push({
	  	    path: '/tuijian',
	  	  	name: 'tuijian',
			query: {
				kw:name
			},
	  	    // params: { menuList: res.data.first_title }
	  	  })
	    // }
	  }
  },
  // computed: {
	 //  newArray () {
  //   console.log(this.newarray)
  //   if (this.newarray) {
  // 	  return this.newarray
  //   } else {
  // 	  return this.sonItem.content
  //   }
	 //  }
  // },
  updated () {
    // console.log(this.sonItem.content)
    //  var index = this.sonItem.content.findIndex(item => item.id === this.sonItemid)
  	// console.log(this.sonItemid)
  	// console.log(index)
    //  console.log(this.sonItem.content.slice(0, index))
    //  console.log(this.sonItem.content.slice(index, -1))
    // var index = this.sonItem.content.findIndex(item => item.id === this.sonItemid)
    // var new1 = this.sonItem.content.slice(index, -1)
    // console.log('newArray', new1)
    // var newArray2 = this.sonItem.content.slice(0, index)
    // console.log('newArray2', newArray2)
    // new1.push(...newArray2)
    // console.log('newArray', new1)
    // this.newarray = new1
  }
}
</script>

<style scoped>
	/* main版块------------start---------------- */
	.main {
		float: left;
		width: 7.8125rem;
		height: 5.625rem;
		padding: 0 0.2rem;
		background-color: #ffffff;
		overflow: auto;
	}

	.main .title {
		font-size: 0.45rem;
		height: 0.75rem;
		color: #000000;
		line-height: 0.75rem;
		border-bottom: 2px solid #D0D0D0;
	}

	.main .main_item {
		width: 100%;
	}

	.main_item .item_name {
		font-size: 0.375rem;
		color: #000000;
		margin-top: 0.125rem;
		margin-left: 0.03125rem;
	}

	.main_item .item_content {
		font-size: 0.3125rem;
		padding-left: 0.25rem;
		color: #6F6F6F
	}

	.main_item .item_content span {
		margin-right: 0.125rem;
	}
</style>
